using UnityEngine;
using UnityEngine.UI;

public class CongratsScreen : UIScreen
{
	public GameObject panel;

	public RawImage skinImage;

	public Button closeButton;

	public Button fbButton;

	public Button twButton;

	private Texture2D tex;

	public void Awake()
	{
		closeButton.onClick.AddListener(ChangeStatus);
		fbButton.onClick.AddListener(ShareOnFacebook);
		twButton.onClick.AddListener(ShareOnTwitter);
	}

	public override void ShowScreen()
	{
		base.ShowScreen();
		if (SkinCollection.Instance.IndexList.Count > 0)
		{
			skinImage.texture = GameManager.Instance.FidgetStore.fidgetTypes[SkinCollection.Instance.IndexList[0]].fidgetLevels[0].texture;
			SkinCollection.Instance.IndexList.RemoveAt(0);
		}
	}

	public void ChangeStatus()
	{
		if (SkinCollection.Instance.IndexList.Count > 0)
		{
			skinImage.texture = GameManager.Instance.FidgetStore.fidgetTypes[SkinCollection.Instance.IndexList[0]].fidgetLevels[0].texture;
			SkinCollection.Instance.IndexList.RemoveAt(0);
		}
		else if (!GameManager.Instance.screenshotTaken)
		{
			UIScreenController.instance.OpenMenu();
		}
		else
		{
			UIScreenController.instance.OpenScreenshot();
		}
	}

	public void ShareOnTwitter()
	{
		if (skinImage.texture != null)
		{
			//UM_ShareUtility.TwitterShare("Hey! Check out #fispio. I've got a new skin! " + Utils.StorePageURL, (Texture2D)skinImage.texture);
			AnalyticManager.SendEvent(AnalyticManager.ShareSkinOnTwitter);
		}
	}

	public void ShareOnFacebook()
	{
		if (skinImage.texture != null)
		{
			//UM_ShareUtility.FacebookShare("Hey! Check out #fispio. I've got a new skin! " + Utils.StorePageURL, (Texture2D)skinImage.texture);
			AnalyticManager.SendEvent(AnalyticManager.ShareSkinOnFacebook);
		}
	}
}
